import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, Index } from 'typeorm';

@Entity('sys_dept')
export class SysDept {
  @PrimaryGeneratedColumn({ type: 'bigint', comment: '主键' })
  id: number;

  @Column({ type: 'varchar', length: 100, comment: '部门名称' })
  name: string;

  @Column({ type: 'varchar', length: 100, comment: '部门编号' })
  @Index('uk_dept_code', { unique: true })
  code: string;

  @Column({ type: 'bigint', default: 0, comment: '父节点id' })
  parent_id: number;

  @Column({ type: 'varchar', length: 255, comment: '父节点id路径' })
  tree_path: string;

  @Column({ type: 'smallint', default: 0, comment: '显示顺序' })
  sort: number;

  @Column({ type: 'tinyint', default: 1, comment: '状态(1-正常 0-禁用)' })
  status: number;

  @CreateDateColumn({
    type: 'timestamp',
    comment: '创建时间',
  })
  create_time: Date;

  @UpdateDateColumn({
    type: 'timestamp',
    comment: '更新时间',
  })
  update_time: Date;

  @Column({ type: 'bigint', nullable: true, comment: '创建人ID' })
  create_by: number;

  @Column({ type: 'bigint', nullable: true, comment: '修改人ID' })
  update_by: number;

  @Column({ type: 'tinyint', default: 0, comment: '逻辑删除标识(1-已删除 0-未删除)' })
  is_deleted: boolean;
}